<!--
 * @Author: your name
 * @Date: 2022-03-08 09:09:18
 * @LastEditTime: 2022-03-08 09:41:54
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \JS\day08\DOM.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DOM</title>
    <script>
        window.onload=function(){   //延迟代码执行  页面文档加载完毕再执行js代码
             console.log('1');
        //警告框
        //阻止代码向下运行
       // alert('代码按照从上到下执行顺序执行');
        var div=document.getElementsByClassName('one')[0];
        console.log(div);
        var div1=document.getElementById('two')
        console.log(div1);
        var div2=document.getElementsByTagName('div')[1];
        console.log(div2);
        /*    document.getElementById('two');
        document.getElementsByClassName('one');
        document.getElementsByName('tree');
        document.getElementsByTagName('div'); */
        
        }
    </script>
</head>

<body>
    <!-- 文档里的任何东西都可以看成结点：文档节点  文本结点 元素结点 注释结点 -->
    hello文本结点
    <div class="one" id="two" >元素结点</div>
    
    <div class="tree"  id="four">我是第二个</div>
    hello
    <!-- 注释结点 -->
</body>
<script>
       
    </script>
</html>